<?php

Raise::load('library.oauth.response.RaiseOAuthResponse');
Raise::load('library.oauth.core.RaiseOAuthUtility');

class RaiseOAuthUserPermissionResponse extends RaiseOAuthResponse {
    
    const KEY_VERIFIER = 'oauth_verifier';
    
    /**
     *
     * @var string
     */
    private $verifier;
    
    public function parse($response) {
        $a = $this->internalParse($response);
        
        $this->token = $a->get(self::KEY_TOKEN);
        $this->verifier = $a->get(self::KEY_VERIFIER);
    }

    public function response() {
        $a = new RaiseCollection();
        $a->add(self::KEY_TOKEN, $this->token);
        $a->add(self::KEY_VERIFIER, $this->verifier);
        
        return RaiseOAuthUtility::buildQuery($a->toArray());
    }
    
    /**
     * Get or set the verifier
     * @param string $v (optional) verifier
     * @return string
     */
    public function verifier($v = null){
        if(func_num_args() == 1){
            $this->verifier = $v;
        }
        return $this->verifier;
    }
    
}
